package com.ruoyi.swPro.swProCategory.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.swPro.swProCategory.domain.SwProCategory;
import com.ruoyi.swPro.swProCategory.service.ISwProCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * sw产品分类Controller
 * 
 * @author ruoyi
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/swProCategory/swProCategory")
public class SwProCategoryController extends BaseController
{
    @Autowired
    private ISwProCategoryService swProCategoryService;

    /**
     * 查询sw产品分类列表
     */
    @PreAuthorize("@ss.hasPermi('swProCategory:swProCategory:list')")
    @GetMapping("/list")
    public AjaxResult list(SwProCategory swProCategory)
    {
        List<SwProCategory> list = swProCategoryService.selectSwProCategoryList(swProCategory);
        return success(list);
    }

    /**
     * 导出sw产品分类列表
     */
    @PreAuthorize("@ss.hasPermi('swProCategory:swProCategory:export')")
    @Log(title = "sw产品分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SwProCategory swProCategory)
    {
        List<SwProCategory> list = swProCategoryService.selectSwProCategoryList(swProCategory);
        ExcelUtil<SwProCategory> util = new ExcelUtil<SwProCategory>(SwProCategory.class);
        util.exportExcel(response, list, "sw产品分类数据");
    }

    /**
     * 获取sw产品分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('swProCategory:swProCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(swProCategoryService.selectSwProCategoryById(id));
    }

    /**
     * 新增sw产品分类
     */
    @PreAuthorize("@ss.hasPermi('swProCategory:swProCategory:add')")
    @Log(title = "sw产品分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SwProCategory swProCategory)
    {
        return toAjax(swProCategoryService.insertSwProCategory(swProCategory));
    }

    /**
     * 修改sw产品分类
     */
    @PreAuthorize("@ss.hasPermi('swProCategory:swProCategory:edit')")
    @Log(title = "sw产品分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SwProCategory swProCategory)
    {
        return toAjax(swProCategoryService.updateSwProCategory(swProCategory));
    }

    /**
     * 删除sw产品分类
     */
    @PreAuthorize("@ss.hasPermi('swProCategory:swProCategory:remove')")
    @Log(title = "sw产品分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(swProCategoryService.deleteSwProCategoryByIds(ids));
    }
}
